export function format(date, format) {
    if (!(date instanceof Date)) {
        date = new Date();
    }
    if (!format) {
        format = 'yyyy-MM-dd';
    }

    return format.replace(/yyyy|MM|dd/g, function (r) {
        switch (r) {
            case 'yyyy':
                return date.getFullYear();
            case 'MM':
                return ('0' + (date.getMonth() + 1)).slice(-2);
            case 'dd':
                return ('0' + date.getDate()).slice('-2');

        }
    })
}